package com.ruoyi.airspaceFlight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.airspaceFlight.domain.TLowairServiceFile;
import com.ruoyi.airspaceFlight.service.ITLowairServiceFileService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 低空文件服务信息Controller
 * 
 * @author ruoyi
 * @date 2023-11-04
 */
@RestController
@RequestMapping("/file")
public class TLowairServiceFileController extends BaseController
{
    @Autowired
    private ITLowairServiceFileService tLowairServiceFileService;

    /**
     * 查询低空文件服务信息列表
     */
//    @RequiresPermissions("airspaceFlight:file:list")
    @GetMapping("/list")
    public TableDataInfo list(TLowairServiceFile tLowairServiceFile)
    {
        startPage();
        List<TLowairServiceFile> list = tLowairServiceFileService.selectTLowairServiceFileList(tLowairServiceFile);
        return getDataTable(list);
    }

    /**
     * 导出低空文件服务信息列表
     */
//    @RequiresPermissions("airspaceFlight:file:export")
    @Log(title = "低空文件服务信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TLowairServiceFile tLowairServiceFile)
    {
        List<TLowairServiceFile> list = tLowairServiceFileService.selectTLowairServiceFileList(tLowairServiceFile);
        ExcelUtil<TLowairServiceFile> util = new ExcelUtil<TLowairServiceFile>(TLowairServiceFile.class);
        util.exportExcel(response, list, "低空文件服务信息数据");
    }

    /**
     * 获取低空文件服务信息详细信息
     */
//    @RequiresPermissions("airspaceFlight:file:query")
    @GetMapping(value = "/{fileId}")
    public AjaxResult getInfo(@PathVariable("fileId") String fileId)
    {
        return AjaxResult.success(tLowairServiceFileService.selectTLowairServiceFileByFileId(fileId));
    }

    /**
     * 新增低空文件服务信息
     */
//    @RequiresPermissions("airspaceFlight:file:add")
    @Log(title = "低空文件服务信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TLowairServiceFile tLowairServiceFile)
    {
        return toAjax(tLowairServiceFileService.insertTLowairServiceFile(tLowairServiceFile));
    }

    /**
     * 修改低空文件服务信息
     */
    @RequiresPermissions("airspaceFlight:file:edit")
    @Log(title = "低空文件服务信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TLowairServiceFile tLowairServiceFile)
    {
        return toAjax(tLowairServiceFileService.updateTLowairServiceFile(tLowairServiceFile));
    }

    /**
     * 删除低空文件服务信息
     */
//    @RequiresPermissions("airspaceFlight:file:remove")
    @Log(title = "低空文件服务信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fileIds}")
    public AjaxResult remove(@PathVariable String[] fileIds)
    {
        return toAjax(tLowairServiceFileService.deleteTLowairServiceFileByFileIds(fileIds));
    }

    @DeleteMapping("/{fileId}")
    public AjaxResult remove(@PathVariable String fileId)
    {
        return toAjax(tLowairServiceFileService.deleteTLowairServiceFileByFileId(fileId));
    }


}
